<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;
use App\Model\AdminUser;
use App\Http\Controllers\Controller;

class LoginController extends Controller
{
	public function index(){
		
		
		return view('admin/login');
	}

	public function login(Request $request){
		$this->validate($request,[
				'email' => 'required|email',
				'password' => 'required|min:6|max:12',
			]);
		$user = request(['email','password']);
		if(\Auth::guard('admins')->attempt($user)){
			return redirect('admin/home/index');
		}

		return \Redirect::back()->withErrors('邮箱密码不匹配');
	}

	public function logout(){
		\Auth::guard('admins')->logout();
		return redirect('login');
	}
}